<?php
namespace juven\controllers {
    \defined( '_JEXEC' ) or die( 'Restricted access' );
    
    class ctrl_groups extends \juven\libs\Controller{
        protected function _init(){
            $this->model = $this->loadModel($this->_unPrefixedControllerName);
        }
        
        public function action_index(){
            $unPrefixedActionName       = $this->unPrefixActionName(__FUNCTION__);
            $this->view->pageTitle      = "Groups";
            $this->view->controllerName = $this->_unPrefixedControllerName;
            $this->view->actionName     = $unPrefixedActionName;
            $this->view->render($this->_unPrefixedControllerName);
        }
        
        public function action_add_group(){
            $unPrefixedActionName       = $this->unPrefixActionName(__FUNCTION__);
            $this->view->pageTitle      = "Groups::Add new group";
            $this->view->controllerName = $this->_unPrefixedControllerName;
            $this->view->actionName     = $unPrefixedActionName;
            $this->view->frm_add_group  = new \juven\forms\groups\frm_add_group($this->_unPrefixedControllerName);
            $this->view->render($this->_unPrefixedControllerName, $unPrefixedActionName);
        }
        
        public function action_edit_group(){
            echo "todo: editGroup";
        }
        
        public function action_delete_group(){
            echo "todo: deleteGroup";
        }
        
        public function action_groupsList2JSON(){
            for ($index = 0; $index < 10000000; $index++){}
            \juven\libs\Tools::sendToClient_JSON($this->model->getGroupsList());
        }
    }
}
?>
